-
Notifications
You must be signed in to change notification settings - Fork 14k
remove let this = self; in compiler
#148955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Some changes occurred in match lowering cc @Nadrieril |
|
☔ The latest upstream changes (presumably #148706) made this pull request unmergeable. Please resolve the merge conflicts. |
|
For at least one case the method used to be a closure passed to |
| block = self | ||
| .in_scope(si, LintLevel::Inherited, |this| { | ||
| this.stmt_expr(block, *expr, Some(*scope)) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See how the code inside this closure uses this, but the code outside the closure uses self?
Being able to consistently use this in both places, regardless of whether they're nested in a closure, is the whole point of doing let this = self. So getting rid of it would make the code harder to read and harder to modify.
|
Switching back to So I don't think this PR should be merged. |
|
I'd agree if it wasn't like that in 7 places, using for inconsistency part I don't agree because as I said places where Here I want to show how inconsistent current version is (for info, there is no reason to use This function uses rust/compiler/rustc_mir_build/src/builder/block.rs Lines 12 to 31 in e1a2ec6
And this function uses rust/compiler/rustc_mir_build/src/builder/block.rs Lines 33 to 42 in e1a2ec6
And here is some more examples that not rename
(And all other function in Moreover, if I remember it correctly, we are not allowing renaming The original idea for this PR comes from that I was reading this code that renaming tldr; around 500 usages of |
I still kept
thisas name for closure argumentI don't know original story why this was
let this = selfbut I don't see any problems to remove itby the way, there is one place, where it's actually necessary and provides a good solution because of macro https://github.com/rust-lang/rust/blob/main/compiler/rustc_parse/src/parser/expr.rs#L495